$(document).ready(function() {
	$("#Sin").click(function() {
		$("#reg").slideUp("fast");
		$("#login").slideDown("fast");
	});
	$("#Sup").click(function() {
		$("#login").slideUp("fast");
		$("#reg").slideDown("fast");
	});
	
	API_ROOT = 'http://localhost:5000';
	url_logIn = '/login';
	url_reg = '/user/register';

	$('#inSub').click(function() {
		var address = $('#emailAddrss').val();
		var password = $('#password').val();
		$.post(url_logIn, {
			'username': address,
			'password': password
			}, function(data) {
			alert('Success!');
		});
	});

	$('#regSub').click(function() {
		var addr = $('#regAddress').val();
		var password = $('#regPassword').val();
		var conpassword = $('#conPassword').val();
		var nickname = $('#nickName').val();
		if ( password == conpassword ) {		
			$.getJSON(url_reg, {
				address: $('#regAddress').val(),
				passwd: $('#regPassword').val(),
				name: $('#nickName').val(),
				fullname: $('#nickName').val()
				}, function(data) {
					alert('Success!');
			});
		} else { alert('Password Error'); }
	});	
});
